//
//  DetailViewController.m
//  08-UITableView-Contact
//
//  Created by LL.F on 16/7/25.
//  Copyright © 2016年 LL.F. All rights reserved.
//

#import "DetailViewController.h"
#import "DetailView.h"
#import "AddViewController.h"

@interface DetailViewController ()

@end

@implementation DetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = [self.contactDic valueForKey:@"name"];
    
    DetailView *nameView = [[DetailView alloc] initWithFrame:CGRectMake(30, 100, 315, 50)];
    nameView.leftLabel.text = @"姓名:";
    nameView.rightLabel.text = [self.contactDic valueForKey:@"name"];
    [self.view addSubview:nameView];
    
    DetailView *ageView = [[DetailView alloc] initWithFrame:CGRectMake(30, 200, 315, 50)];
    ageView.leftLabel.text = @"年龄:";
    
    // NSNumber转成NSString类型
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    if ([[self.contactDic valueForKey:@"age"] isKindOfClass:[NSNumber class]]) {
         ageView.rightLabel.text  = [numberFormatter stringFromNumber:[self.contactDic valueForKey:@"age"]];
    } else if ([[self.contactDic valueForKey:@"age"] isKindOfClass:[NSString class]]) {
    
        ageView.rightLabel.text  = [self.contactDic valueForKey:@"age"];
    }
   
    [self.view addSubview:ageView];

    DetailView *genderView = [[DetailView alloc] initWithFrame:CGRectMake(30, 300, 315, 50)];
    genderView.leftLabel.text = @"性别:";
    genderView.rightLabel.text = [self.contactDic valueForKey:@"gender"];
    [self.view addSubview:genderView];

    DetailView *phoneNumberView = [[DetailView alloc] initWithFrame:CGRectMake(30, 400, 315, 50)];
    phoneNumberView.leftLabel.text = @"电话:";
    phoneNumberView.rightLabel.text = [self.contactDic valueForKey:@"phoneNumber"];
    [self.view addSubview:phoneNumberView];
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
